#include <iostream>
#include <signal.h>
#include <unistd.h>
using namespace std;

void handler(int signum)
{
    cout << "获取了一个信号:" << signum << endl;
}

int main()
{
    struct sigaction act, oact;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    act.sa_handler = handler;

    // 设置进当前进程的PCB中
    sigaction(2, &act, &oact);

    cout << "default action:" << (int)oact.sa_handler << endl;

    while (1) sleep(1);
    return 0;
}
